pixelcache: check whether cached surface and cairo_t scales match
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 11 Dec 2013 14:41:08 +0000 (15:41 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Wed, 22 Jan 2014 16:10:05 +0000 (17:10 +0100)
gtk/gtkpixelcache.c

index 71c78330d838feb735f630cbc65be7d1f5fcef6e..4cc07171d7639769bd1fe766a55009347886d07f 100644 (file)
@@ -396,6 +396,19 @@ blow_cache_cb  (gpointer user_data)
   return G_SOURCE_REMOVE;
 }
 
+static gboolean
+context_is_unscaled (cairo_t *cr)
+{
+  cairo_matrix_t matrix;
+  gdouble x, y;
+
+  x = y = 1;
+  cairo_get_matrix (cr, &matrix);
+  cairo_matrix_transform_distance (&matrix, &x, &y);
+
+  return x == 1 && y == 1;
+}
+
 
 void
 _gtk_pixel_cache_draw (GtkPixelCache *cache,
@@ -420,7 +433,7 @@ _gtk_pixel_cache_draw (GtkPixelCache *cache,
   _gtk_pixel_cache_set_position (cache, view_rect, canvas_rect);
   _gtk_pixel_cache_repaint (cache, draw, view_rect, canvas_rect, user_data);
 
-  if (cache->surface &&
+  if (cache->surface && context_is_unscaled (cr) &&
       /* Don't use backing surface if rendering elsewhere */
       cairo_surface_get_type (cache->surface) == cairo_surface_get_type (cairo_get_target (cr)))
     {